<?php
/**
 * Created by PhpStorm.
 * 产品查看类（用于加盟商查看产品的保内外情况，和本身的产品管理中的查看分开）
 * User: lyb
 * Date: 2017/1/12
 * Time: 10:23
 */

class product_view extends MY_Controller{
    function __construct()
    {
        parent::__construct();
        //加载模型
        $this->load->model('product_sap_model','sapModel');
    }

    public function index(){
        $siteList[0]=array('id'=>1,'name'=>'ES');
        $siteList[1]=array('id'=>2,'name'=>'UK');
        $siteList[2]=array('id'=>3,'name'=>'DE');
        $siteList[3]=array('id'=>4,'name'=>'RU');
        $siteList[4]=array('id'=>5,'name'=>'US');
        $siteList[5]=array('id'=>6,'name'=>'OMS');
        $siteList[6]=array('id'=>7,'name'=>'FR');
        $siteList[7]=array('id'=>8,'name'=>'SZ');
        //$siteList[6]=array('id'=>7,'name'=>'ETA');
        $data['siteList']=$siteList;
        $this->load->view('defaults/sap/index_view',$data);
        $this->load->view('defaults/common/footer');
    }

    /**
     * 产品列表
     */
    public function productList(){
        $gp=gp();
        $gp['page']=$gp['page']?$gp['page']:1;
        $gp['keyword']=trim($gp['keyword']);
        $str="?site=".$gp['site']."&keyword=".$gp['keyword'];
        //分页查询
        $this->load->library('pagination');
        $config['page_query_string'] = TRUE;
        $config['base_url'] = blang_url('productClassify/product_view/productList'.$str);
        $config['total_rows'] = $this->sapModel->getProductNum($gp['site'],$gp['keyword']);
        $config['uri_segment'] = config_item('enable_lang')?5:4;
        $config['per_page'] = 15;
        $this->pagination->initialize($config);
        $data['pageShow']= $this->pagination->create_links();
        //分页结束
        $dataList=$this->sapModel->getProductView($gp['site'],$gp['keyword'],($gp['page']-1)*$config['per_page'],$config['per_page']);
        $data['dataList']=$dataList;
        $data['keyword']=$gp['keyword'];
        $data['site']=$gp['site'];
        $this->load->view('defaults/sap/type_view',$data);
        $this->load->view('defaults/common/footer');
    }

    /**
     * 产品列表
     */
    public function brandList(){
        $gp=gp();
        $gp['page']=$gp['page']?$gp['page']:1;
        $gp['keyword']=trim($gp['keyword']);
        $str="?site=".$gp['site'].'&tid='.$gp['tid']."&keyword=".$gp['keyword'];
        //分页查询
        $this->load->library('pagination');
        $config['page_query_string'] = TRUE;
        $config['base_url'] = blang_url('productClassify/product_view/brandList'.$str);
        $config['total_rows'] = $this->sapModel->getBrandNum($gp['site'],$gp['tid'],$gp['keyword']);
        $config['uri_segment'] = config_item('enable_lang')?5:4;
        $config['per_page'] = 15;
        $this->pagination->initialize($config);
        $data['pageShow']= $this->pagination->create_links();
        //分页结束
        $dataList=$this->sapModel->getBrandView($gp['site'],$gp['tid'],$gp['keyword'],($gp['page']-1)*$config['per_page'],$config['per_page']);
        $data['dataList']=$dataList;
        $data['keyword']=$gp['keyword'];
        $data['site']=$gp['site'];
        $data['tid']=$gp['tid'];
        $this->load->view('defaults/sap/brand_view',$data);
        $this->load->view('defaults/common/footer');
    }
    /**
     * 产品列表
     */
    public function modelList(){
        $gp=gp();
        $gp['page']=$gp['page']?$gp['page']:1;
        $gp['keyword']=trim($gp['keyword']);
        $str="?site=".$gp['site'].'&tid='.$gp['tid'].'&bid='.$gp['bid']."&keyword=".$gp['keyword'];
        //分页查询
        $this->load->library('pagination');
        $config['page_query_string'] = TRUE;
        $config['base_url'] = blang_url('productClassify/product_view/modelList'.$str);
        $config['total_rows'] = $this->sapModel->getModelNum($gp['site'],$gp['tid'],$gp['bid'],$gp['keyword']);
        $config['uri_segment'] = config_item('enable_lang')?5:4;
        $config['per_page'] = 15;
        $this->pagination->initialize($config);
        $data['pageShow']= $this->pagination->create_links();
        //分页结束
        $dataList=$this->sapModel->getModelView($gp['site'],$gp['tid'],$gp['bid'],$gp['keyword'],($gp['page']-1)*$config['per_page'],$config['per_page']);
        $data['dataList']=$dataList;
        $data['keyword']=$gp['keyword'];
        $data['site']=$gp['site'];
        $data['tid']=$gp['tid'];
        $data['bid']=$gp['bid'];
        $this->load->view('defaults/sap/model_view',$data);
        $this->load->view('defaults/common/footer');
    }
}